package sshFile;


import java.io.PrintStream;
import org.apache.commons.net.telnet.TelnetClient;
 

/**
 * 执行脚本代码
 * @author Administrator
 *
 */
public class TelnetZteTool {
	private TelnetClient telnet = new TelnetClient();
	private PrintStream out;
 
	// 普通用户结束
	public TelnetZteTool(String ip, int port, String user, String password,String fileName) {
		try {
	//		System.out.println("准备执行：");
			telnet.connect(ip, port);
			out = new PrintStream(telnet.getOutputStream());
			write("SZHQ");
			write("Huqiao@123");
			System.out.println("登录成功.");
			write("SET AMO:NAME=\"OMMB8\"");
			write("FDD_QUERYCELLSTATUS:SUBNET=450304,NE=194871,EUTRANCELLID=1;");
			System.out.println("执行成功.");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
 
	/** * 写操作 * * @param value */
	public void write(String value) {
		try {
			out.println(value);
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
 
	/** * 关闭连接 */
	public void disconnect() {
		try {
			telnet.disconnect();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
 
	public static void main(String[] args) {
		try {
			System.out.println("启动Telnet test4 ...");
			String ip = "132.225.250.5";
			int port = 31114;
			String user = "SZHQ";
			String password = "Huqiao@123";
			TelnetZteTool telnet = new TelnetZteTool(ip, port, user, password,"lst.txt");

			telnet.disconnect();
			System.out.println("end ...");
		} catch (Exception e) {
			System.out.println("e:"+e.getMessage());
			e.printStackTrace();
		}
	}
}